package com.polaris.live.dialog

import android.content.Context
import android.content.Intent
import androidx.activity.result.ActivityResult
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.common.basic.ActivityLauncher
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.databinding.DialogPwsErrorProhibitLoginBinding
import com.polaris.live.ui.login.verify.SetPasswordActivity

/**
 * 密码错误无法登录
 *
 * @author Created by 长空 on 2023/11/09/004 10:49
 */
class PwsErrorProhibitLoginDialog(
    context: Context,
    val areaCode: String,
    val phoneNumber: String,
    val gmail: String,
    val launcher: ActivityLauncher
) : CenterPopupView(context) {

    private lateinit var mBinding: DialogPwsErrorProhibitLoginBinding
    override fun getImplLayoutId(): Int {
        return R.layout.dialog_pws_error_prohibit_login
    }

    override fun onCreate() {
        super.onCreate()
        mBinding = DialogPwsErrorProhibitLoginBinding.bind(popupImplView)
        mBinding.tvCancel.setOnSingleClickListener {
            dismiss()
        }
        mBinding.tvForgetPws.setOnSingleClickListener {
            launch(launcher, areaCode, phoneNumber, gmail) {

            }
            dismiss()
        }
    }

    companion object {
        fun launch(
            launcher: ActivityLauncher,
            areaCode: String,
            phoneNumber: String,
            mGmail: String,
            callback: ((ActivityResult) -> Unit)? = null
        ) {
            Intent().apply {
                setClass(launcher.context, SetPasswordActivity::class.java)
                putExtra("isLogin", true)
                putExtra("isFirstSet", false)
                putExtra("phoneNumber", phoneNumber)
                putExtra("gmail", mGmail)
                putExtra("areaCode", areaCode)
            }.let { launcher.launch(it, callback) }
        }
    }

}